package com.trial.personal;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class StartupIntentReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		
		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); 
	       NetworkInfo info = cm.getActiveNetworkInfo(); 
	       if (info != null && info.getType() == ConnectivityManager.TYPE_WIFI) { 
	           if (info.isConnected()) { 
	               //start service 
	        	   Intent serviceIntent = new Intent();
	       		serviceIntent.setAction("com.trial.personal.MonitorService");
	       		context.startService(serviceIntent);
	       		
	           } 
	           else { 
	               //stop service 
	        	   Intent serviceIntent = new Intent();
	       		serviceIntent.setAction("com.trial.personal.MonitorService");
	       		context.stopService(serviceIntent);
	       		
	           } 
	       } 
	       else
	       {
	    	   Intent serviceIntent = new Intent();
	       		serviceIntent.setAction("com.trial.personal.MonitorService");
	       		context.stopService(serviceIntent);
	       }

		
		
	}

}
